package com.hzit.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;


/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Configuration
@PropertySource("classpath:properties/jdbc.properties")
@Data
public class JdbcConfig {
	@Value("${db.url}")
	String url;
	@Value("${db.driver}")
	String driverClassName;
	@Value("${db.username}")
	String username;
	@Value("${db.password}")
	String password;

	@Bean
	public DataSource dataSource() {
		DruidDataSource dataSource = new DruidDataSource();
		dataSource.setUrl(url);
		dataSource.setDriverClassName(driverClassName);
		dataSource.setUsername(username);
		dataSource.setPassword(password);
		return dataSource;
	}

}
